﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Entity;

namespace BLL
{
    public class ModuleVo
    {
        public string ModuleID { get; set; }
        public string MOduleName { get; set; }
        public string DisplayName { get; set; }
        public ModuleVo ParentModule { get; set; }
        public List<ModuleVo> Children { get; set; }
        public string ModuleURL { get; set; }

        ModuleDao moduleDao = new ModuleDao();

        public ModuleVo()
        {
            ModuleID = "";
            MOduleName = "";
            DisplayName = "";
            ParentModule = null;
            Children = new List<ModuleVo>();
            ModuleURL = "";
        }

        public void getChildren()
        {
            List<ModuleVo> children = new List<ModuleVo>();
            List<BoModules> modules = moduleDao.GetChildModules(ModuleID);
            foreach (BoModules module in modules)
            {
                ModuleVo child = new ModuleVo();
                child.ModuleID = module.MOD_ID;
                child.MOduleName = module.MOD_NAME;
                child.DisplayName = module.MOD_DISPLAYNAME;
                child.ModuleURL = module.MOD_URL;
                child.ParentModule = this;
                child.getChildren();
                children.Add(child);
            }
            Children = children;
        }
    }
}
